<template>
  <div class="form-block-inner">
    <Form ref="formItem" :rules="ruleValidate" :model="formItem" label-position="top">
      <div class="title-style">{{headTitle}}</div>
      <Row :gutter="16">
        <Col span="12">
          <FormItem prop="project_name" label="项目资金名称:">
            <Input  v-model="formItem.project_name" placeholder="请输入项目资金名称"/>
          </FormItem>
        </Col>
        <Col span="12">
          <FormItem prop="budget" label="资金额度:">
            <Input  v-model="formItem.budget" type="number" placeholder="请输入资金额度">
              <span slot="append">万元</span>
            </Input>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="16">
        <Col span="12">
          <FormItem prop="capital_source" label="资金来源:">
            <Input  v-model="formItem.capital_source" placeholder="请输入资金来源"></Input>
          </FormItem>
        </Col>
        <Col span="12">
          <FormItem prop="target_no" label="指标文号:">
            <Input v-model="formItem.target_no" placeholder="请输入资金来源"></Input>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="16">
        <Col span="12">
          <FormItem prop="project_cycle" label="项目周期：" >
            <Input  v-model="formItem.project_cycle" placeholder="请输入项目周期"/>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem prop="settle_cycle" label="结算周期:">
            <RadioGroup v-model="formItem.settle_cycle">
              <!-- <Radio label="1">一次性</Radio>-->
              <Radio label="2">周结算</Radio>
              <Radio label="3">月结算</Radio>
              <Radio label="4">季度结算</Radio>
              <Radio label="5">年度结算</Radio>
              <Radio label="99">其他</Radio>
            </RadioGroup>
          </FormItem>
        </Col>
        <Col span="4">
          <template v-if="formItem.settle_cycle == '99'">
            <FormItem prop="settle_cycle_other" label="其他结算周期：">
              <Input v-model="formItem.settle_cycle_other" placeholder="请输入其他结算周期"/>
            </FormItem>
          </template>
        </Col>
      </Row>
      <Row :gutter="16">
        <!--        <Col span="24">-->
        <!--          <FormItem  label="结算账户：" v-model="formItem.pay_account" :required="true">-->
        <!--            <Divider  size="small">零余额账户</Divider>-->
        <!--          </FormItem>-->
        <!--        </Col>-->
        <Col span="24">
          <FormItem prop="settle_account_bank" label="零余额账户开户银行：">
            <RadioGroup v-model="formItem.settle_account_bank">
              <Radio label="盛京银行"></Radio>
              <Radio label="中国工商银行"></Radio>
              <Radio label="中国建设银行"></Radio>
              <Radio label="中国农业银行"></Radio>
              <Radio label="中国银行"></Radio>
              <Radio label="中国交通银行"></Radio>
              <Radio label="中国邮政储蓄银行"></Radio>
              <Radio label="中信银行"></Radio>
              <Radio label="光大银行"></Radio>
              <Radio label="招商银行"></Radio>
              <Radio label="浦发银行"></Radio>
              <Radio label="民生银行"></Radio>
              <Radio label="华夏银行"></Radio>
              <Radio label="平安银行"></Radio>
              <Radio label="兴业银行"></Radio>
              <Radio label="广发银行"></Radio>
              <Radio label="渤海银行"></Radio>
              <Radio label="浙商银行"></Radio>
              <Radio label="恒丰银行"></Radio>
              <Radio label="其他"></Radio>
              <div v-if="formItem.settle_account_bank == '其他'" class="other-style">
                <Input v-model="formItem.other_settle_account_bank"  placeholder="请输入零余额账户开户银行"/>
              </div>
            </RadioGroup>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="16">
        <!--        <Col span="24">-->
        <!--          <Divider  size="small">实体账户</Divider>-->
        <!--        </Col>-->
        <Col span="24">
          <FormItem prop="pay_account_banks" label="实体账户支付银行：">
            <CheckboxGroup v-model="formItem.pay_account_banks" @on-change="selectOptionTwo" placeholder="请选择支付银行">
              <Checkbox label="盛京银行"></Checkbox>
              <Checkbox label="中国工商银行"></Checkbox>
              <Checkbox label="中国建设银行"></Checkbox>
              <Checkbox label="中国农业银行"></Checkbox>
              <Checkbox label="中国银行"></Checkbox>
              <Checkbox label="中国交通银行"></Checkbox>
              <Checkbox label="中国邮政储蓄银行"></Checkbox>
              <Checkbox label="中信银行"></Checkbox>
              <Checkbox label="光大银行"></Checkbox>
              <Checkbox label="招商银行"></Checkbox>
              <Checkbox label="浦发银行"></Checkbox>
              <Checkbox label="民生银行"></Checkbox>
              <Checkbox label="华夏银行"></Checkbox>
              <Checkbox label="平安银行"></Checkbox>
              <Checkbox label="兴业银行"></Checkbox>
              <Checkbox label="广发银行"></Checkbox>
              <Checkbox label="渤海银行"></Checkbox>
              <Checkbox label="浙商银行"></Checkbox>
              <Checkbox label="恒丰银行"></Checkbox>
              <Checkbox label="其他"></Checkbox>
              <div v-if="showCheck" class="other-style">
                <Input v-model="formItem.other_pay_account_banks"  placeholder="请输入实体账户支付银行"/>
              </div>
            </CheckboxGroup>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="16">
        <!--        <Col span="24">-->
        <!--          <Divider  size="small">市财政直接拨付</Divider>-->
        <!--        </Col>-->
        <Col span="24">
          <FormItem  prop="settle_account_direct" label="市财政直接拨付：">
            <CheckboxGroup v-model="formItem.settle_account_direct">
              <Checkbox label="1">市财政直接拨付</Checkbox>
            </CheckboxGroup>
          </FormItem>
        </Col>
        <Col span="24" style="margin-top: 20px">
          <FormItem prop="project_instruction" label="项目说明：">
            <Input v-model="formItem.project_instruction" type="textarea" :autosize="{minRows: 3,maxRows: 5}" placeholder="请输入项目说明"></Input>
          </FormItem>
        </Col>
      </Row>
      <Row :gutter="16">
        <!--规则-->
        <Col span="24">
          <div class="title-style">设定规则</div>
          <div v-for="(item,index) in dataList" :key="index">
            <Row :gutter="20">
              <Col span="10">
                <FormItem label="规则内容：" prop="gz_content">
                  <Input v-model="item.gz_content" type="textarea" :autosize="{minRows: 2,maxRows: 3}"
                         placeholder="请填写规则内容"></Input>
                </FormItem>
                <!--                <FormItem class="required" label="规则内容：" prop="gz_content">-->
                <!--                  <Input  v-model="item.gz_content" placeholder="请填写规则内容"></Input>-->
                <!--                </FormItem>-->
              </Col>
              <Col span="10">
                <FormItem label="规则依据：" prop="gz_yi_ju">
                  <Input v-model="item.gz_yi_ju" type="textarea" :autosize="{minRows: 2,maxRows: 3}"
                         placeholder="请填写规则依据的文件内容"></Input>
                </FormItem>
              </Col>
            </Row>
            <Row :gutter="20">
              <Col span="10">
                <FormItem class="required" prop="gz_type" label="规则类型:">
                  <RadioGroup v-model="item.gz_type">
                    <Radio label="1">必要</Radio>
                    <Radio label="2">联合</Radio>
                    <Radio label="3">附加</Radio>
                  </RadioGroup>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label=" " class="col-last-btn">
                  <Button @click="delAction(index)" type="error" shape="circle" icon="md-close"></Button>
                </FormItem>

              </Col>
            </Row>
            <Row v-if="item.gz_type == 2">
              <Col span="20">
                <FormItem class="required" label="联合规则：" prop="lh_yi_ju">
                  <Input v-model="item.lh_yi_ju" type="textarea" :autosize="{minRows: 2,maxRows: 3}"
                         placeholder="选择联合时,请填写不同规则间的关联关系"></Input>
                </FormItem>
              </Col>
            </Row>
            <Divider class="mt10"/>
          </div>
          <Row >
            <Col span="24">
              <Button type="success" @click="add">添加</Button>
            </Col>
          </Row>
        </Col>

        <!--              条件-->
        <Col span="24" style="margin-top: 27px">
          <div class="title-style">设定条件</div>
          <div v-for="(item,index) in wheredataList" :key="index">
            <Row :gutter="20">
              <Col span="10">
                <FormItem class="required" label="条件内容：" prop="tj_content">
                  <Input v-model="item.tj_content" type="textarea" :autosize="{minRows: 2,maxRows: 3}"
                         placeholder="请填写条件内容。如：年龄、户籍等限制条件"></Input>
                </FormItem>
                <!--                <FormItem class="required" label="条件内容：" prop="tj_content">-->
                <!--                  <Input v-model="item.tj_content" placeholder="请填写条件内容。如：年龄、户籍等限制条件"></Input>-->
                <!--                </FormItem>-->
              </Col>
              <Col span="10">
                <FormItem label="条件依据：" prop="tj_yi_ju">
                  <Input v-model="item.tj_yi_ju" type="textarea" :autosize="{minRows: 2,maxRows: 3}"
                         placeholder="请填写条件依据的文件内容"></Input>
                </FormItem>
              </Col>
            </Row>
            <Row :gutter="20">
              <Col span="10">
                <FormItem class="required" prop="tj_xian_zhi" label="条件限制:">
                  <RadioGroup v-model="item.tj_xian_zhi">
                    <Radio label="1">必要</Radio>
                    <Radio label="2">联合</Radio>
                    <Radio label="3">附加</Radio>
                  </RadioGroup>
                </FormItem>
              </Col>
              <Col span="11">

                <FormItem label=" " class="col-last-btn">
                  <Button @click="wheredelAction(index)" type="error" shape="circle" icon="md-close"></Button>
                </FormItem>
              </Col>
            </Row>
            <Row v-if="item.tj_xian_zhi == 2">
              <Col span="20">
                <FormItem class="required" label="联合条件：" prop="lh_yi_ju">
                  <Input v-model="item.lh_yi_ju" type="textarea" :autosize="{minRows: 2,maxRows: 3}"
                         placeholder="选择联合时,请填写不同条件间的关联关系"></Input>
                </FormItem>
              </Col>
            </Row>
            <Divider class="mt10"/>
          </div>
          <Row >
            <Col span="24">
              <Button type="success" @click="whereadd">添加</Button>
            </Col>
          </Row>
        </Col>

        <!--              要件-->
        <Col span="24" style="margin-top: 27px">
          <div class="title-style">设定要件</div>
          <div v-for="(item,index) in yaojiandataList" :key="index">
            <Row :gutter="24">
              <Col span="10">
                <FormItem class="required" prop="yj_title" label="要件名称:">
                  <Input v-model="item.yj_title" placeholder="请填写要件名称"></Input>
                </FormItem>
              </Col>
              <Col span="7">
                <FormItem class="required" prop="yj_type" label="要件类型:">
                  <Select v-model="item.yj_type" style="width:100%">
                    <!--<Option value="表单">表单</Option>-->
                    <Option value="1">附件</Option>
                    <Option value="2">制式电子表单</Option>
                    <Option value="3">制式电子文本</Option>
                  </Select>
                </FormItem>
              </Col>
              <Col span="6">
                <FormItem prop="yi_img_demo" label="要件样本:">
                  <Button icon="ios-cloud-upload-outline" style="width: 46%"  @click="uploadImgAction(item, index)">上传</Button>
                  <span class="upload-icon">
                            <Icon type="md-checkmark-circle" size="18" v-if="item.yi_img_demo" color="green"/>
                            <Icon type="md-close-circle" size="18" v-else color="red"/>
                            </span>
                </FormItem>
              </Col>
              <template v-if="item.yj_type == '1'">
                <Col span="8">
                  <FormItem class="required" prop="is_fu_yong" label="是否可复用要件:">
                    <RadioGroup v-model="item.is_fu_yong">
                      <Radio label="是"></Radio>
                      <Radio label="否"></Radio>
                    </RadioGroup>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem class="required" prop="is_xian_chang_cai_ji" label="是否现场采集:">
                    <RadioGroup v-model="item.is_xian_chang_cai_ji">
                      <Radio label="是"></Radio>
                      <Radio label="否"></Radio>
                    </RadioGroup>
                  </FormItem>
                </Col>
                <Col span="8">
                  <FormItem prop="file_type" label="上传方式:">
                    <CheckboxGroup v-model="item.file_type" @on-change="checkBoxChange">
                      <Checkbox label="JPG"></Checkbox>
                      <Checkbox label="PNG"></Checkbox>
                      <Checkbox label="PDF"></Checkbox>
                      <Checkbox label="Word"></Checkbox>
                      <Checkbox label="Excel"></Checkbox>
                    </CheckboxGroup>
                  </FormItem>
                </Col>
              </template>
            </Row>
            <Row :gutter="20" class="row-m-t">
              <Col span="10">
                <FormItem label="要件依据：" prop="tj_yi_ju">
                  <Input v-model="item.yj_yi_ju" type="textarea" :autosize="{minRows: 2,maxRows: 3}"
                         placeholder="请填写要件依据的文件内容"></Input>
                </FormItem>
                <!--                <FormItem prop="" label="要件依据:">-->
                <!--                  <Input  placeholder="请填写要件依据的文件内容" v-model="item.yj_yi_ju"></Input>-->
                <!--                </FormItem>-->
              </Col>

              <Col span="11">
                <FormItem label=" " class="col-last-btn">
                  <Button @click="yaojiandelAction(index)" type="error" shape="circle" icon="md-close"></Button>
                </FormItem>
              </Col>
              <Divider class="mt10"/>
            </Row>
          </div>
          <Row>
            <Col span="24">
              <Button type="success" @click="yaojianadd">添加</Button>
            </Col>
          </Row>
          <import-imgs ref="imgService" :index="yaojiancurrentIndex" @result="importImgsResultAction"></import-imgs>
        </Col>

        <!--              时限-->
        <Col span="24" style="margin-top: 27px">
          <div class="title-style">设定时限</div>
          <Row>
            <div v-for="(item,index2) in timedataList" :key="index2">
              <Row :gutter="16"  :key="index2">
                <Col span="12">
                  <span>
                    <DatePicker type="date" v-model="item.sj_num" placeholder="开始时间" style="width: 200px"></DatePicker>
                    <span style="margin-left: 5px;margin-right: 5px">-</span>
                    <DatePicker type="date" v-model="item.end_time" placeholder="结束时间" style="width: 200px"></DatePicker>
                  </span>
                </Col>
                <!--                <Col span="16">-->
                <!--                  <FormItem label=" " class="col-last-btn">-->
                <!--                    <Button @click="timedelAction(index2)" type="error" shape="circle" icon="md-close"></Button>-->
                <!--                  </FormItem>-->
                <!--                </Col>-->
                <!--                <Col span="24">-->
                <!--                  <FormItem prop="sj_yi_ju" label="时限依据：">-->
                <!--                    <Input v-model="item.sj_yi_ju" type="textarea" :autosize="{minRows: 2,maxRows: 3}"-->
                <!--                           placeholder="请填写时限依据的文件内容"></Input>-->
                <!--                  </FormItem>-->
                <!--                </Col>-->
                <!--                <Divider class="mb10"/>-->

              </Row>
            </div>
            <!--            <Row>-->
            <!--              <Col span="24" style="margin-left: 8px">-->
            <!--                <Button type="success" @click="timeadd()">添加</Button>-->
            <!--              </Col>-->
            <!--            </Row>-->
          </Row>
        </Col>
      </Row>
      <Divider/>
      <div class="button-group">
        <Button type="primary" @click="saveBtnAction" :loading="btnLoading">保存数据</Button>
      </div>
    </Form>
  </div>
</template>

<script>
import {
  insert,
  selectById,
  projectUpdate
} from '@/api/setting/private'
import '@/assets/css/link.css'
import ImportImgs from '../capital-manage/project-capital/CreateMoney/components/yaojian-setting/components/import-imgs'
export default {
  components: {
    ImportImgs
  },
  data () {
    return {
      timedataList: [{ gov_base_id: this.$route.query.id }], // 时限
      yaojiandataList: [], // 要件
      yaojiannodeList: [], // 要件
      yaojiancurrentIndex: 0, // 要件
      wheredataList: [], // 条件
      wherenodeList: [], // 条件
      dataList: [], // rouler
      nodeList: [], // rouler
      tipTitle: '指事项各个节点上报、审核或审批时应该遵循的规则。', // rouler
      flowDataList: [],
      tabName: '',
      baseInfoId: '',
      showSubobj: false,
      showSubway: false,
      showSetto: false,
      showCheckOne: false,
      showCheck: false,
      showCheckThree: false,
      ruleValidate: {
        other_settle_account_bank: [
          { required: true, message: '零余额账户开户银行', trigger: 'blur' }
        ],
        other_settle_account_banks: [
          { required: true, message: '请输入其结算银行', trigger: 'blur' }
        ],
        other_pay_account_banks: [{
          required: true, message: '请输入实体账户支付银行', trigger: 'blur'
        }],
        other_pay_account_bank: [{
          required: true, message: '请输入其支付银行', trigger: 'blur'
        }],
        other_subsidy_bank: [
          { required: true, message: '请输入其结算银行', trigger: 'blur' }
        ],
        project_name: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' }
        ],
        project_type: [
          { required: true, message: '补贴类型不能为空', trigger: 'change' }
        ],
        project_type_build: [
          { required: true, message: '建设类项目不能为空', trigger: 'change' }
        ],
        project_type_other: [
          { required: true, message: '其他项目类型不能为空', trigger: 'blur' }
        ],
        budget: [
          { required: true, message: '请填写正确金额', trigger: 'blur' }
        ],
        capital_source: [
          { required: true, message: '资金来源不能为空', trigger: 'change' }
        ],
        target_no: [
          { required: true, message: '指标文号不能为空', trigger: 'change' }
        ],
        capital_source_other: [
          { required: true, message: '其他来源不能为空', trigger: 'blur' }
        ],
        project_cycle: [
          { required: true, message: '项目周期不能为空', trigger: 'blur' }
        ],
        issue_cycle: [
          { required: true, message: '发放周期不能为空', trigger: 'change' }
        ],
        issue_cycle_other: [
          { required: true, message: '其他发放周期不能为空', trigger: 'blur' }
        ],
        settle_cycle: [
          { required: true, message: '结算周期不能为空', trigger: 'change' }
        ],
        settle_cycle_other: [
          { required: true, message: '其他结算周期不能为空', trigger: 'blur' }
        ],
        subsidy_object: [
          { required: true, type: 'array', min: 1, message: '补贴对象不能为空', trigger: 'change' }
        ],
        subsidy_object_other: [
          { required: true, message: '其他补贴对象不能为空', trigger: 'blur' }
        ],
        settle_object: [
          { required: true, type: 'array', min: 1, message: '结算对象不能为空', trigger: 'change' }
        ],
        settle_object_other: [
          { required: true, message: '其他结算对象不能为空', trigger: 'blur' }
        ],
        subsidy_way: [
          { required: true, type: 'array', min: 1, message: '补贴方式不能为空', trigger: 'change' }
        ],
        subsidy_way_other: [
          { required: true, message: '其他补贴方式不能为空', trigger: 'blur' }
        ]
        // subsidy_bank: [
        //   { required: true, type: 'array', min: 1, message: '补贴代发银行不能为空', trigger: 'change' }
        // ]
        // pay_account: [
        //   { required: true, message: '支付账户不能为空', trigger: 'change' }
        // ],
        // pay_account_bank: [
        //   { required: true, message: '支付银行不能为空', trigger: 'change' }
        // ],
        // pay_account_banks: [
        //   { required: true, type: 'array', min: 1, message: '支付银行不能为空', trigger: 'change' }
        // ],
        // settle_account: [
        //   { required: true, message: '结算账户不能为空', trigger: 'change' }
        // ],
        // settle_account_bank: [
        //   { required: true, message: '结算银行不能为空', trigger: 'change' }
        // ],
        // settle_account_banks: [
        //   { required: true, type: 'array', min: 1, message: '结算银行不能为空', trigger: 'change' }
        // ]
      },
      formItem: {},
      btnLoading: false,
      projectSource: [
        {
          value: '1',
          label: '国家'
        },
        {
          value: '2',
          label: '市本级财政资金'
        },
        {
          value: '3',
          label: '区县'
        },
        {
          value: '99',
          label: '其他'
        }
      ],
      payBank: [
        {
          value: '中国工商银行',
          label: '中国工商银行'
        },
        {
          value: '中国建设银行',
          label: '中国建设银行'
        },
        {
          value: '中国农业银行',
          label: '中国农业银行'
        },
        {
          value: '中国银行',
          label: '中国银行'
        },
        {
          value: '中国交通银行',
          label: '中国交通银行'
        },
        {
          value: '中国邮政储蓄银行',
          label: '中国邮政储蓄银行'
        },
        {
          value: '中信银行',
          label: '中信银行'
        },
        {
          value: '光大银行',
          label: '光大银行'
        },
        {
          value: '招商银行',
          label: '招商银行'
        },
        {
          value: '浦发银行',
          label: '浦发银行'
        },
        {
          value: '民生银行',
          label: '民生银行'
        },
        {
          value: '华夏银行',
          label: '华夏银行'
        },
        {
          value: '平安银行',
          label: '平安银行'
        },
        {
          value: '兴业银行',
          label: '兴业银行'
        }, {
          value: '广发银行',
          label: '广发银行'
        }, {
          value: '渤海银行',
          label: '渤海银行'
        },
        {
          value: '浙商银行',
          label: '浙商银行'
        },
        {
          value: '恒丰银行',
          label: '恒丰银行'
        },
        {
          value: '盛京银行',
          label: '盛京银行'
        }
      ],
      settleBank: [
        {
          value: '中国工商银行',
          label: '中国工商银行'
        },
        {
          value: '中国建设银行',
          label: '中国建设银行'
        },
        {
          value: '中国农业银行',
          label: '中国农业银行'
        },
        {
          value: '中国银行',
          label: '中国银行'
        },
        {
          value: '中国交通银行',
          label: '中国交通银行'
        },
        {
          value: '中国邮政储蓄银行',
          label: '中国邮政储蓄银行'
        },
        {
          value: '中信银行',
          label: '中信银行'
        },
        {
          value: '光大银行',
          label: '光大银行'
        },
        {
          value: '招商银行',
          label: '招商银行'
        },
        {
          value: '浦发银行',
          label: '浦发银行'
        },
        {
          value: '民生银行',
          label: '民生银行'
        },
        {
          value: '华夏银行',
          label: '华夏银行'
        },
        {
          value: '平安银行',
          label: '平安银行'
        },
        {
          value: '兴业银行',
          label: '兴业银行'
        }, {
          value: '广发银行',
          label: '广发银行'
        }, {
          value: '渤海银行',
          label: '渤海银行'
        },
        {
          value: '浙商银行',
          label: '浙商银行'
        },
        {
          value: '恒丰银行',
          label: '恒丰银行'
        },
        {
          value: '盛京银行',
          label: '盛京银行'
        }
      ],
      optionType: 'add',
      projectID: '',
      rtobj: {},
      salatype: '',
      headTitle: ''
    }
  },
  mounted () {
    if (this.$route.query.id) {
      this.projectID = this.$route.query.id
      this.optionType = 'edit'
      this.getInfoByID()
    } else {
      this.optionType = 'add'
    }
    if (this.$route.query.zjtype) {
      console.log(this.$route.query.zjtype, 'zjtypeWWW')
      this.salatype = this.$route.query.zjtype
      if (this.salatype === '1') {
        this.headTitle = '惠民资金'
      } if (this.salatype === '2') {
        this.headTitle = '惠企资金'
      }
    }
    this.baseInfoId = this.$route.query.id
      ? this.$route.query.id
      : this.baseInfoId
  },
  methods: {
    dayin () {
      console.log(this.timedataList)
    },
    // 时限----------------------------------------------------------
    timeadd () {
      this.timedataList.push({ gov_base_id: this.$route.query.id })
    },
    timedelAction (index) {
      this.timedataList.splice(index, 1)
    },

    // 要件-------------------------------------------------------------------------------------------------------
    uploadImgAction (item, index) {
      let path = item.yi_img_demo
      this.yaojiancurrentIndex = index
      this.$refs.imgService.modelAction(path)
    },
    checkBoxChange (val) {
      this.yaojiandataList = this.$common.xeUtils.clone(this.yaojiandataList)
    },
    importImgsResultAction (path, index) {
      this.$set(this.yaojiandataList[index], 'yi_img_demo', path)
    },
    yaojianadd () {
      this.yaojiandataList.push({ gov_base_id: this.$route.query.id })
    },
    yaojiandelAction (index) {
      this.yaojiandataList.splice(index, 1)
    },

    // 规则-------------------------------------------------------------------------------------------------------
    add () {
      this.dataList.push({ gov_base_id: this.$route.query.id })
    },
    delAction (index) {
      this.dataList.splice(index, 1)
    },

    // 条件-------------------------------------------------------------------------------------------------------
    whereadd () {
      this.wheredataList.push({ gov_base_id: this.$route.query.id })
    },
    wheredelAction (index) {
      this.wheredataList.splice(index, 1)
    },

    setFlowDataAction (data) {
      data.map((item) => {
        item.YaoJianList = []
        item.whereList = []
        item.ruleList = []
        item.timeList = []
        item.compareList = []
        item.loopList = []
        item.warningList = []
        item.nodeList = []
        item.problemList = []
        item.evaluateList = []
        item.powerList = []
        item.gov_base_id = this.baseInfoId
        return item
      })
      this.flowDataList = data
    },
    resultAction (data) {
      this.flowDataList = data
    },
    sett (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSetto = true
      } else {
        this.showSetto = false
        delete this.formItem.settle_object_other
      }
    },
    setto (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSetto = true
      } else {
        this.showSetto = false
        delete this.formItem.settle_object_other
      }
    },
    subway (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSubway = true
      } else {
        this.showSubway = false
        delete this.formItem.subsidy_way_other
      }
    },
    subobj (val) {
      let bank = val.toString()
      if (bank.indexOf('99') >= 0) {
        this.showSubobj = true
      } else {
        this.showSubobj = false
        delete this.formItem.subsidy_object_other
      }
    },
    selectOptionOne (val) {
      let banks = val.toString()
      if (banks.indexOf('其他') >= 0) {
        this.showCheckOne = true
      } else {
        this.showCheckOne = false
        delete this.formItem.other_subsidy_bank
      }
    },
    selectOptionTwo (val) {
      let banks = val.toString()
      if (banks.indexOf('其他') >= 0) {
        this.showCheck = true
      } else {
        this.showCheck = false
        delete this.formItem.other_pay_account_banks
      }
    },
    selectOption (val) {
      let banks = val.toString()
      if (banks.indexOf('其他') >= 0) {
        this.showCheckThree = true
      } else {
        this.showCheckThree = false
        delete this.formItem.other_settle_account_banks
      }
    },
    getInfoByID () {
      selectById({ id: this.projectID }).then(ret => {
        console.log(ret, '88888')
        let data = ret.data
        if (data.errcode === 0) {
          this.dataList = this.$common.xeUtils.clone(ret.data.data.ruleList)

          this.timedataList = this.$common.xeUtils.clone(ret.data.data.timeList)
          this.wheredataList = this.$common.xeUtils.clone(ret.data.data.whereList)
          console.log(data.data.yaoJianList, '22')
          this.yaojiandataList = this.$common.xeUtils.clone(ret.data.data.yaoJianList)
          this.yaojiandataList.forEach(item => {
            if (item.file_type) {
              item.file_type = JSON.parse(item.file_type)
            }
          })
          this.formItem = data.data
          if (this.formItem.type === '1') {
            this.headTitle = '惠民资金'
          } if (this.formItem.type === '2') {
            this.headTitle = '惠企资金'
          }
          // console.log(this.formItem.subsidy_bank.toString(), '6666')
          let banks = this.formItem.subsidy_bank.toString()
          if (banks.indexOf('其他') >= 0) {
            this.showCheckOne = true
          } else {
            this.showCheckOne = false
            delete this.formItem.other_subsidy_bank
          }
          let bank1 = this.formItem.pay_account_banks.toString()
          if (bank1.indexOf('其他') >= 0) {
            this.showCheck = true
          } else {
            this.showCheck = false
            delete this.formItem.other_pay_account_banks
          }
          let bank2 = this.formItem.settle_account_banks.toString()
          if (bank2.indexOf('其他') >= 0) {
            this.showCheckThree = true
          } else {
            this.showCheckThree = false
            delete this.formItem.other_settle_account_banks
          }
          let bank3 = this.formItem.settle_object.toString()
          if (bank3.indexOf('99') >= 0) {
            this.showSetto = true
          } else {
            this.showSetto = false
            delete this.formItem.settle_object_other
          }
          let bank4 = this.formItem.subsidy_way.toString()
          if (bank4.indexOf('99') >= 0) {
            this.showSubway = true
          } else {
            this.showSubway = false
            delete this.formItem.subsidy_way_other
          }
          let bank5 = this.formItem.subsidy_object.toString()
          if (bank5.indexOf('99') >= 0) {
            this.showSubobj = true
          } else {
            this.showSubobj = false
            delete this.formItem.subsidy_object_other
          }
        } else {
          this.error(data)
        }
      })
    },
    saveBtnAction () {
      if (this.formItem.project_type === '1') {
        if (this.$common.xeUtils.isEmpty(this.formItem.subsidy_bank) && this.$common.xeUtils.isEmpty(this.formItem.subsidy_cash)) {
          this.$Message.error('补贴代发银行、现金发放至少选一类')
        } else {
          if (this.$common.xeUtils.isEmpty(this.formItem.pay_account_bank) && this.$common.xeUtils.isEmpty(this.formItem.pay_account_banks) && this.$common.xeUtils.isEmpty(this.formItem.pay_account_direct)) {
            this.$Message.error('零余额、实体账户、市财政直接拨付至少选一类')
          } else {
            if (this.showCheckOne) {
              if (this.formItem.other_subsidy_bank === undefined || this.formItem.other_subsidy_bank === '') {
                this.$Message.error('开户银行不能为空')
                return
              }
            }
            if (this.showCheck) {
              if (this.formItem.other_pay_account_banks === undefined || this.formItem.other_pay_account_banks === '') {
                this.$Message.error('实体账户支付银行不能为空')
                return
              }
            }
            if (this.showCheckThree) {
              if (this.formItem.other_settle_account_banks === undefined || this.formItem.other_settle_account_banks === '') {
                this.$Message.error('结算银行不能为空')
                return
              }
            }
            if (this.formItem.pay_account_bank === '其他') {
              if (this.formItem.other_pay_account_bank === undefined || this.formItem.other_pay_account_bank === '') {
                this.$Message.error('实体账户支付银行不能为空')
                return
              }
            }
            if (this.formItem.settle_account_bank === '其他') {
              if (this.formItem.other_settle_account_bank === undefined || this.formItem.other_settle_account_bank === '') {
                this.$Message.error('零余额账户开户银行不能为空')
                return
              }
            }
            let param = {}
            if (this.formItem.subsidy_bank === '' || this.formItem.subsidy_bank === undefined) {
              this.formItem.subsidy_bank = []
            }
            if (this.formItem.pay_account_banks === '' || this.formItem.pay_account_banks === undefined) {
              this.formItem.pay_account_banks = []
            }
            if (this.formItem.settle_account_banks === '' || this.formItem.settle_account_banks === undefined) {
              this.formItem.settle_account_banks = []
            }
            if (this.formItem.pay_account_direct === '' || this.formItem.pay_account_direct === undefined) {
              this.formItem.pay_account_direct = []
            }
            if (this.formItem.settle_account_direct === '' || this.formItem.settle_account_direct === undefined) {
              this.formItem.settle_account_direct = []
            }
            if (this.formItem.subsidy_object === '' || this.formItem.subsidy_object === undefined) {
              this.formItem.subsidy_object = []
            }
            if (this.formItem.settle_object === '' || this.formItem.settle_object === undefined) {
              this.formItem.settle_object = []
            }
            if (this.formItem.subsidy_way === '' || this.formItem.subsidy_way === undefined) {
              this.formItem.subsidy_way = []
            }
            if (this.formItem.subsidy_cash === '' || this.formItem.subsidy_cash === undefined) {
              this.formItem.subsidy_cash = []
            }
            if (this.optionType === 'add') {
              this.formItem.type = this.salatype
              this.formItem.ruleList = this.dataList
              this.formItem.timeList = this.timedataList
              this.formItem.timeList.forEach(item => {
                item.sj_num = this.$common.xeUtils.toDateString(item.sj_num)
                item.end_time = this.$common.xeUtils.toDateString(item.end_time)
              })
              this.formItem.whereList = this.wheredataList
              this.formItem.yaojianList = this.yaojiandataList
              this.formItem.yaojianList.forEach(item => {
                item.file_type = JSON.stringify(item.file_type)
              })
              param = this.formItem
              // this.$delete(param, 'id')
            } else if (this.optionType === 'edit') {
              // this.formItem.type = this.salatype
              this.formItem.ruleList = this.dataList
              this.formItem.timeList = this.timedataList
              this.formItem.timeList.forEach(item => {
                item.sj_num = this.$common.xeUtils.toDateString(item.sj_num)
                item.end_time = this.$common.xeUtils.toDateString(item.end_time)
              })
              this.formItem.whereList = this.wheredataList
              this.formItem.yaojianList = this.yaojiandataList
              this.formItem.yaojianList.forEach(item => {
                item.file_type = JSON.stringify(item.file_type)
              })
              param = this.formItem
              if (this.$route.query.id) param.id = this.$route.query.id
            }
            this.$refs['formItem'].validate((valid) => {
              if (valid) {
                if (this.optionType === 'add') {
                  this.addDataAction(param)
                } else if (this.optionType === 'edit') {
                  this.updateDataAction(param)
                }
              } else {
                this.$Message.error({
                  content: '操作失败,请核对添加信息后重试'
                })
              }
            })
          }
        }
      } else if (this.formItem.project_type !== '1') {
        if (this.$common.xeUtils.isEmpty(this.formItem.settle_account_bank) && this.$common.xeUtils.isEmpty(this.formItem.settle_account_banks) && this.$common.xeUtils.isEmpty(this.formItem.settle_account_direct)) {
          this.$Message.error('零余额、实体账户、市财政直接拨付至少选一类')
        } else {
          if (this.showCheckOne) {
            if (this.formItem.other_subsidy_bank === undefined || this.formItem.other_subsidy_bank === '') {
              this.$Message.error('开户银行不能为空')
              return
            }
          }
          if (this.showCheck) {
            if (this.formItem.other_pay_account_banks === undefined || this.formItem.other_pay_account_banks === '') {
              this.$Message.error('实体账户支付银行不能为空')
              return
            }
          }
          if (this.showCheckThree) {
            if (this.formItem.other_settle_account_banks === undefined || this.formItem.other_settle_account_banks === '') {
              this.$Message.error('结算银行不能为空')
              return
            }
          }
          if (this.formItem.pay_account_bank === '其他') {
            if (this.formItem.other_pay_account_bank === undefined || this.formItem.other_pay_account_bank === '') {
              this.$Message.error('支付银行不能为空')
              return
            }
          }
          if (this.formItem.settle_account_bank === '其他') {
            if (this.formItem.other_settle_account_bank === undefined || this.formItem.other_settle_account_bank === '') {
              this.$Message.error('零余额账户开户银行不能为空')
              return
            }
          }
          let param = {}
          if (this.formItem.subsidy_bank === '' || this.formItem.subsidy_bank === undefined) {
            this.formItem.subsidy_bank = []
          }
          if (this.formItem.pay_account_banks === '' || this.formItem.pay_account_banks === undefined) {
            this.formItem.pay_account_banks = []
          }
          if (this.formItem.settle_account_banks === '' || this.formItem.settle_account_banks === undefined) {
            this.formItem.settle_account_banks = []
          }
          if (this.formItem.pay_account_direct === '' || this.formItem.pay_account_direct === undefined) {
            this.formItem.pay_account_direct = []
          }
          if (this.formItem.settle_account_direct === '' || this.formItem.settle_account_direct === undefined) {
            this.formItem.settle_account_direct = []
          }
          if (this.formItem.subsidy_object === '' || this.formItem.subsidy_object === undefined) {
            this.formItem.subsidy_object = []
          }
          if (this.formItem.settle_object === '' || this.formItem.settle_object === undefined) {
            this.formItem.settle_object = []
          }
          if (this.formItem.subsidy_way === '' || this.formItem.subsidy_way === undefined) {
            this.formItem.subsidy_way = []
          }
          if (this.formItem.subsidy_cash === '' || this.formItem.subsidy_cash === undefined) {
            this.formItem.subsidy_cash = []
          }
          if (this.optionType === 'add') {
            this.formItem.type = this.salatype
            this.formItem.ruleList = this.dataList
            this.formItem.timeList = this.timedataList
            this.formItem.timeList.forEach(item => {
              item.sj_num = this.$common.xeUtils.toDateString(item.sj_num)
              item.end_time = this.$common.xeUtils.toDateString(item.end_time)
            })
            this.formItem.whereList = this.wheredataList
            this.formItem.yaojianList = this.yaojiandataList
            this.formItem.yaojianList.forEach(item => {
              item.file_type = JSON.stringify(item.file_type)
            })
            param = this.formItem
            // this.$delete(param, 'id')
          } else if (this.optionType === 'edit') {
            console.log(this.yaojiandataList, 'this.yaojiandataList')
            // this.formItem.type = this.salatype
            this.formItem.ruleList = this.dataList
            this.formItem.timeList = this.timedataList
            this.formItem.timeList.forEach(item => {
              item.sj_num = this.$common.xeUtils.toDateString(item.sj_num)
              item.end_time = this.$common.xeUtils.toDateString(item.end_time)
            })
            this.formItem.whereList = this.wheredataList
            this.formItem.yaojianList = this.yaojiandataList
            this.formItem.yaojianList.forEach(item => {
              item.file_type = JSON.stringify(item.file_type)
            })
            param = this.formItem
            if (this.$route.query.id) param.id = this.$route.query.id
          }
          this.$refs['formItem'].validate((valid) => {
            if (valid) {
              if (this.optionType === 'add') {
                this.addDataAction(param)
              } else if (this.optionType === 'edit') {
                this.updateDataAction(param)
              }
            } else {
              this.$Message.error({
                content: '操作失败,请核对添加信息后重试'
              })
            }
          })
        }
      }
    },
    updateDataAction (param) {
      console.log(param, '修改')
      let stas = param.type
      this.btnLoading = true
      projectUpdate(param).then(ret => {
        let data = ret.data
        if (data.errcode === 0) {
          this.btnLoading = false
          this.$Message.success('操作成功')
          this.$router.push({
            name: 'privateList',
            query: { sts: stas }
          })
          // this.$router.push({ name: 'projectList' })
        } else {
          this.btnLoading = false
          this.error(data)
        }
      })
    },
    addDataAction (param) {
      console.log(param, '添加')
      this.btnLoading = true
      insert(param).then(ret => {
        // console.log(ret, 'ret!!!add')
        this.rtobj = ret.data.data
        let data = ret.data
        if (data.errcode === 0) {
          this.btnLoading = false
          this.success()
          this.$router.push({
            name: 'privateList',
            query: { sts: this.salatype }
          })
        } else {
          this.btnLoading = false
          this.error(data)
          this.$router.push({ name: 'privateList' })
        }
      })
    },
    // confirmd () {
    //   this.$Modal.confirm({
    //     title: '请前往完善行权事项信息',
    //     content: '<p>请前往完善行权事项信息</p>',
    //     loading: true,
    //     onOk: () => {
    //       setTimeout(() => {
    //         this.$Modal.remove()
    //         this.$router.push({
    //           name: 'createList',
    //           query: { id: this.rtobj.id, vtype: '2', project_name: this.rtobj.project_name }
    //         })
    //       }, 200)
    //     }
    //   })
    // },
    success (val) {
      val = this.$common.xeUtils.isEmpty(val) ? '操作成功' : val
      this.$Message.success(val)
    },
    error (data) {
      this.$Message.error({
        content: '操作失败,\n' + data.errmsg
      })
    }
  }
}
</script>

<style scoped lang="less">
.type-style /deep/ .ivu-col-span-8 {
  margin-left: -4%;
}
.type-style-one /deep/ .ivu-col-span-8 {
  margin-left: -2%;
}
.type-style-three /deep/ .ivu-col-span-8 {
  margin-left: -11%;
}
.type-style-four /deep/ .ivu-col-span-8 {
  margin-left: -3%;
}
.type-style-five /deep/ .ivu-col-span-8 {
  margin-left: -11%;
}
.input-one {
  margin-left: 10px;
}

.form-block-inner {
  height: 100%;
}

.tag-box {
  margin-bottom: 10px;
}

/deep/ .ivu-col-span-2 {
  margin-top: 23px;
}

.button-group {
  text-align: center;
}

.upload-icon {
  padding-left: 10px;
}

/deep/ .ivu-tooltip {
  /*width: 100%;*/
}

.excel-help {
  display: inline-block;
  margin-left: 10px;
  font-size: 16px;
  color: orange;
  cursor: pointer;
}

.other-style {
  display: inline-flex;
  margin-left: -2%;
}
</style>
